using UnityEngine;
using UnityEngine.UI;

public class DisplayGameBestTime : GenericDialog
{
	public Text minsecText;

	public Text hundredsText;

	public Image slider;

	public Image sliderBg;

	private float displayTime;

	private void LateUpdate()
	{
		if (displayTime != 0f)
		{
			float levelTime = Game.levelTime;
			slider.fillAmount = Mathf.Clamp((displayTime - levelTime) / displayTime, 0f, 1f);
		}
	}

	private void UpdateTime(float timeInSeconds)
	{
		int minutes;
		int seconds;
		int hundreds;
		Utils.GetSplitedTime(timeInSeconds, out minutes, out seconds, out hundreds);
		minsecText.text = minutes.ToString("00") + ":" + seconds.ToString("00") + ".";
		hundredsText.text = hundreds.ToString("00");
	}

	public void Reset()
	{
		UpdateTime(0f);
		slider.fillAmount = 1f;
	}

	public void SetTime(float timeInSeconds)
	{
		displayTime = timeInSeconds;
		UpdateTime(timeInSeconds);
	}

	public override void Show()
	{
		base.Show();
		slider.gameObject.SetActive(true);
		sliderBg.gameObject.SetActive(true);
	}

	public override void Hide()
	{
		base.Hide();
		slider.gameObject.SetActive(false);
		sliderBg.gameObject.SetActive(false);
	}
}
